//
//  CommentOnFeedRequest.m
//  collection
//
//  Created by zhangjing on 5/6/12.
//  Copyright (c) 2012 Tsinghua University. All rights reserved.
//

#import "CommentOnFeedRequest.h"

@implementation CommentOnFeedRequest

- (void)initParams {
    
    self.descriptionName = @"note.comment";
    
    RequestData* requestData = [[CommentOnFeedRequestData alloc] init];
    self.request = requestData;
    [requestData release];
    
    Response* response = [[CommentOnFeedResponse alloc] init];
    self.response = response;
    [response release];
}

- (NSString*)buildRequestURL {
    
    CommentOnFeedRequestData* requestData = (CommentOnFeedRequestData*)self.request;
    
    NSString* requestContent = [NSString stringWithFormat:@"&uid=%lld&note=%@&replyNoteId=%lld&replyUserId=%lld",
                                requestData.UID,
                                requestData.comment,
                                requestData.FID,
                                requestData.rUID];
    
    return requestContent;
}

- (void)parseResponse:(NSObject *)data {
    
    CommentOnFeedResponse* response = (CommentOnFeedResponse*)self.response;
    
    NSDictionary* dic = (NSDictionary*)data;
    
    NSString* value = nil;
    
    // FID
    value = [dic objectForKey:@"noteId"];
    if (value != nil && ![value isEqualToString:@""]) {
        response.FID = value.longLongValue;
    }
    
    // MID
    value = [dic objectForKey:@"commentId"];
    if (value != nil && ![value isEqualToString:@""]) {
        response.MID = value.longLongValue;
    }
    
    // comment number
    value = [dic objectForKey:@"commentNum"];
    if (value != nil && ![value isEqualToString:@""]) {
        response.commentNum = value.longLongValue;
    }
}

@end
